package com.czy.owner.ui.garage;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;

import com.czy.owner.R;
import com.czy.owner.entity.CarBrandModel;
import com.czy.owner.global.Constants;
import com.czy.owner.ui.BaseActivity;
import com.czy.owner.utils.MyLog;
import com.czy.owner.widget.PageTitleView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by King on 2016/6/8 0008.
 */
public class PickBrandActivity extends BaseActivity {

    public static final String START_FLAG = "start_flag";
    public static final int REQUEST_BRAND_CODE = 100;
    @BindView(R.id.btn_page_back)
    Button btnPageBack;
    @BindView(R.id.rb_sel_by_self)
    RadioButton rbSelBySelf;
    @BindView(R.id.rb_sel_by_scan)
    RadioButton rbSelByScan;
    @BindView(R.id.rg_sel_car_brand_title)
    RadioGroup rgSelCarBrandTitle;
    @BindView(R.id.fg_sel_car_brand_container)
    FrameLayout fgSelCarBrandContainer;
    PageTitleView pageTitle;
    private FragmentManager fragmentManager;
    private FragmentTransaction fragmentTransaction;

    private PickBrandFragment pickBrandFragment;
    private ScanBrandFragment scanBrandFragment;

    private RadioButton rbSelected;

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_pick_brand;
    }

    @Override
    protected void initInjector() {

    }

    @OnClick({R.id.btn_page_title_left})
    protected void onViewClicked(View view){
        switch (view.getId()){
            case R.id.btn_page_title_left:
                PickBrandActivity.this.onBackPressed();
                break;
        }
    }

    @Override
    protected void initViews() {
        fragmentManager = getSupportFragmentManager();
        fragmentTransaction = fragmentManager.beginTransaction();
        pickBrandFragment = new PickBrandFragment();
        scanBrandFragment = new ScanBrandFragment();
//        rgSelCarBrandTitle.check(R.id.rb_sel_by_self);
//        rgSelCarBrandTitle.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
//            @Override
//            public void onCheckedChanged(RadioGroup group, int checkedId) {
//                switch (checkedId) {
//                    case R.id.rb_sel_by_self:
//                        fragmentManager.beginTransaction().hide(scanBrandFragment).show(pickBrandFragment).commit();
//                        rbSelected = rbSelBySelf;
//                        break;
//                    case R.id.rb_sel_by_scan:
//                        fragmentManager.beginTransaction().hide(pickBrandFragment).show(scanBrandFragment).commit();
//                        rbSelected = rbSelByScan;
//                        break;
//                }
//            }
//        });


        fragmentTransaction.add(R.id.fg_sel_car_brand_container, pickBrandFragment);
        fragmentTransaction.add(R.id.fg_sel_car_brand_container, scanBrandFragment);
        fragmentTransaction.show(pickBrandFragment).hide(scanBrandFragment).commit();
        pageTitle = new PageTitleView((RelativeLayout) findViewById(R.id.rl_page_title), "自助选车", true);
    }

    @Override
    protected void updateViews() {

    }
}
